/*
 * @Author: jiu yin
 * @Date: 2024-04-10 10:16:29
 * @LastEditTime: 2024-04-17 13:02:03
 * @LastEditors: jiu yin zhen jing
 * @FilePath: \web-smart-tour\vue.config.js
 * jiu
 */

const UnoCSS = require('unocss-webpack-uniapp2').default
const {
	codeInspectorPlugin
} = require('code-inspector-plugin');
const TransformPages = require('./src/router/utils/uni-read-pages')
const path = require('path')
const {
	webpack
} = new TransformPages()

module.exports = {
	transpileDependencies: ['uview-ui'],

	configureWebpack: {
		module: {
			rules: [{
				test: /\.vue$/,
				use: {
					loader: path.resolve(__dirname, "./node_modules/vue-inset-loader")
				},
			}]
		},
		plugins: [
			// https://github.com/unocss/unocss
			UnoCSS(),
			new webpack.DefinePlugin({
				ROUTES: webpack.DefinePlugin.runtimeValue(() => {
					const tfPages = new TransformPages({
						includes: ['path', 'name', 'aliasPath', 'meta']
					});
					return JSON.stringify(tfPages)
				}, true)
			}),
		],
	},

	chainWebpack: (config) => {
		config.plugin('code-inspector-plugin').use(
			codeInspectorPlugin({
				bundler: 'webpack',
			})
		);
	},
}